/**
 * v-auth
 * 按钮权限指令
 */
import type { Directive, DirectiveBinding } from 'vue'
import usePermission from '@/hooks/usePermission'
const auth: Directive = {
  mounted(el: HTMLElement, binding: DirectiveBinding) {
    const { value } = binding
    if (value && typeof value == 'string') {
      const { hasCurrentButton } = usePermission()
      if (!hasCurrentButton(value)) el.remove()
    }
  }
}

export default auth
